/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ParserTemplateDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.ParserTemplateDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ParserTemplateDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_parser_template.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisParserTemplateDAO extends SqlMapClientDaoSupport implements ParserTemplateDAO {

    /**
     *  Query DB table <tt>sgw_parser_template</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, channel_system_id, out_trans_code_id, groovy_content, memo, gmt_create, gmt_modified, groovy_class_name, gateway_mode from sgw_parser_template</tt>
     *
     *	@return List<ParserTemplateDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<ParserTemplateDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-PARSER-TEMPLATE-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>ParserTemplateDO</tt> object to DB table <tt>sgw_parser_template</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_parser_template(id,channel_system_id,out_trans_code_id,groovy_content,memo,groovy_class_name,gateway_mode,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param parserTemplate
     *	@return int
     *	@throws DataAccessException
     */
    public int insert(ParserTemplateDO parserTemplate) throws DataAccessException {
        if (parserTemplate == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-PARSER-TEMPLATE-INSERT", parserTemplate);

        return parserTemplate.getId();
    }

    /**
     *  Update DB table <tt>sgw_parser_template</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_parser_template set channel_system_id=?, out_trans_code_id=?, groovy_content=?, memo=?, groovy_class_name=?, gmt_modified=sysdate, gateway_mode=? where (id = ?)</tt>
     *
     *	@param channelSystemId
     *	@param outTransCodeId
     *	@param groovyContent
     *	@param memo
     *	@param groovyClassName
     *	@param gatewayMode
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String channelSystemId, String outTransCodeId, String groovyContent,
                      String memo, String groovyClassName, String gatewayMode, int id)
                                                                                      throws DataAccessException {
        Map param = new HashMap();

        param.put("channelSystemId", channelSystemId);
        param.put("outTransCodeId", outTransCodeId);
        param.put("groovyContent", groovyContent);
        param.put("memo", memo);
        param.put("groovyClassName", groovyClassName);
        param.put("gatewayMode", gatewayMode);
        param.put("id", new Integer(id));

        return getSqlMapClientTemplate().update("MS-PARSER-TEMPLATE-UPDATE", param);
    }

    /**
     *  Query DB table <tt>sgw_parser_template</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, channel_system_id, out_trans_code_id, groovy_content, memo, groovy_class_name, gmt_create, gmt_modified, gateway_mode from sgw_parser_template where ((out_trans_code_id = ?) AND (channel_system_id = ?) AND (groovy_class_name = ?))</tt>
     *
     *	@param outTransCodeId
     *	@param channelSystemId
     *	@param groovyClassName
     *	@return List<ParserTemplateDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<ParserTemplateDO> select(String outTransCodeId, String channelSystemId,
                                         String groovyClassName) throws DataAccessException {
        Map param = new HashMap();

        param.put("outTransCodeId", outTransCodeId);
        param.put("channelSystemId", channelSystemId);
        param.put("groovyClassName", groovyClassName);

        return getSqlMapClientTemplate().queryForList("MS-PARSER-TEMPLATE-SELECT", param);

    }

    /**
     *  Delete records from DB table <tt>sgw_parser_template</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_parser_template where (id = ?)</tt>
     *
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(int id) throws DataAccessException {
        Integer param = new Integer(id);

        return getSqlMapClientTemplate().delete("MS-PARSER-TEMPLATE-DELETE", param);
    }

}